<template>
  <div>
    <table-data ref="table" :config="table_config" :searchFormConfig="search_form_config">
      <template v-slot:test="slotData" >
        <el-button @click="edit(slotData)" size="small" >编辑</el-button>
      </template>
    </table-data>
    <lease-type-add :flagVisible.sync="dialog_show" :data="currentItemData"/>
  </div>
</template>

<script>
import { getCarsAttrs, getCarsTypeAttrs } from "@/api/carsAttr.js"
import TableData from "@c/tableData"
import LeaseTypeAdd from "@c/dialog/leaseTypeAdd.vue"

export default {
  name: "CarsAttr",
  components: {
    TableData,
    LeaseTypeAdd
  },
  data() {
    return {
      currentItemData: {}, // 当前公用属性数据
      dialog_show: false,
      table_config: {
        checkbox: false,
        isShowSearchForm: true,
        thead:[
          {label:"租车类型",prop:"carsLeaseTypeName"},
          {label:"禁启状态",prop:"carsLeaseStatus",type:"switch",handler:(data)=>this.leaseStatus(data)},
          {label:"车辆列表",prop:"carsList",width:500},
          {
            label:"操作",
            type:"operation",
            // default: {
            //   deleteBtn: true,
            //   deleteKey: "carsLeaseTypeId",
            // },
            slotName: "test"
          },
        ],
        url: "leaseList",
        data: {
          pageSize: 10,
          pageNumber: 1
        }
      },
      table_loading: false,
      search_form_config: {
        form_item: [
          {label:"关键字",type:"Keyword",options: ["carsLeaseTypeName","carsNumber"]},
        ],
        form_handler: [
          {label: "新增", prop:"add", type:"success",element:"btn",handler:()=>this.showDialog()},
        ]
      },
      form: {
        area: "",
        type: "",
        status: "",
      },
      carsListBtn: [],
      carsListBtnId: "",
      dataId: ""
    }
  },
  methods: {
    showDialog() {
      this.dialog_show = true;
    },
    leaseStatus(data) {
      console.log(data)
    },
    edit(data) {
      this.currentItemData = Object.assign({},data.data);
      // this.currentItemData = JSON.parse(JSON.stringify(data.data));
      this.dialog_show = true;
    }
  }
}
</script>

<style lang="scss" scoped>

</style>